<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
    <input id="msg" type="text"/><button onclick="send()">发送</button>
</div>
</body>
<script>
    var ws = new WebSocket("ws://localhost:8280/ws/test");
    ws.onopen = function(evt) {
        console.log("Connection open ...");
        // ws.send("Hello WebSockets!");
    };

    ws.onmessage = function(evt) {
        console.log( "Received Message: " + evt.data);
        // ws.close();
    };

    ws.onclose = function(evt) {
        console.log("Connection closed.");
    };
    function send() {
        var elementById = document.getElementById("msg");
        ws.send(elementById.value);
    }
</script>
</html>